﻿namespace eLearning.Model
{
    public class User
    {
        public enum UserType { Dosen, Mahasiswa, Admin, Denied }

        public string Id { get; set; }
        public string IdUser { get; set; }
        public string Username { get; set; }
        public string Nama { get; set; }
        public string Password { get; set; }
        public UserType Type { get; set; }
        public bool Saved { get; set; }

        public override string ToString()
        {
            return Nama;
        }

        public object ConvertUser()
        {
            if (Type == Model.User.UserType.Admin ||
                Type == Model.User.UserType.Dosen)
            {
                Dosen dosen = new Dosen();
                dosen.Nip = IdUser;
                dosen.Username = Username;
                dosen.Password = Password;
                dosen.Nama = Nama;
                return dosen;
            }
            else if (Type == Model.User.UserType.Mahasiswa)
            {
                Mahasiswa mhs = new Mahasiswa();
                mhs.Id = Id;
                mhs.Nim = IdUser;
                mhs.Username = Username;
                mhs.Password = Password;
                mhs.Nama = Nama;
                return mhs;
            }
            return null;
        }
    }
}
